<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义函数与调用</title>
</head>
<body>
<script>
    function getSum(n, m) {
        var sum = 0;
        if (n > m) {
            var temp = n;
            n = m;
            m = temp;
        }
        for (var i = n; i <= m; i++) {
            sum += i;
        }
        return sum;
    }
    alert("5 到 10 之间的数相加为：" + getSum(5, 10));
    alert("100 到 1000 之间的数相加为：" + getSum(100, 1000))
</script>
</body>
</html>